# -*- coding: utf-8 -*-
# @Author：fanmingxiang@touty.io
# @Date  ：2022/2/28 14:24
import os

from appium import webdriver
from tools.read_yaml import read_yaml


class GetDriver:

    __Web_Driver = None

    @classmethod
    def get_web_driver(cls):
        if cls.__Web_Driver is None:
            cls.__Web_Driver = webdriver.Remote('http://localhost:4723/wd/hub', read_yaml('desired_caps'))
            cls.__Web_Driver.implicitly_wait(10)
        return cls.__Web_Driver

    @classmethod
    def quit_web_driver(cls):
        if cls.__Web_Driver:
            cls.__Web_Driver.quit()
            cls.__Web_Driver = None
            # os.system('allure generate ./report/report-data -o ./report/allure-reports/ --clean')
            # os.system('allure serve report/report-data')
